<?php
require_once("../../Config.php");
require_once("../../Class/ClassMysql.php");
require_once("../../Class/ClassCheck.php");
require_once("../../Class/ClassResult.php");

//json头
header("Content-type: application/json");

session_start();
if(!isset($_SESSION["name"])) {
    exit(Result::jsonReturn(1, "未登录"));
}

$uid = $_SESSION["id"];
$uname = $_SESSION["name"];
$uemail = $_SESSION["email"];
$upower = $_SESSION["power"];


// 校验是否为空
if(Check::isEmpty($_POST["id"])) {
    exit(Result::jsonReturn(1, "缺少参数"));
}

$id = 0;
// 校验是否符合格式
if(Check::isNum($_POST["id"])) {
    $id = (int)$_POST["id"];
}else {
    exit(Result::jsonReturn(1, "参数格式错误"));
}

$db = new DB();
$sql = "DELETE FROM qilian_contents WHERE id={$id} AND user_id={$uid}";
if($db->delete($sql)) {
    exit(Result::jsonReturn(0, "删除文章成功", array(
        "id"=>(int)$id)));
}else {
    exit(Result::jsonReturn(1, "删除文章失败"));
}



?>